package WaiBao;

import java.util.Arrays;

public class YangLiTing {
    public static void main(String[] args) {
        String[] name = {"张鱼(班长)","杜紫藤(团支书)", "小李(学习委员)","安小鸟(文艺委员)", "陈凯", "沈眉", "梁志超", "诸葛青", "张初岚", "冯宝宝", "徐三", "徐四",
                "肖自在", "王也", "陈朵", "王振求", "张子维", "张怀意", "田晋中", "陈静", "田金凤", "陆槿", "吕良", "马仙红", "王蔼", "吕慈", "高二壮", "曲彤",
                "无根生", "杨立挺(学生)"};//考生本人: 杨立挺(学生)
        int[] age = {20, 18, 19, 20, 21, 22, 20, 21, 20, 19, 19, 19, 19, 20, 20, 19, 18, 18, 18, 18, 19, 19, 20, 20, 20, 20, 20,20,20, 20};//最后一位：考生年龄:20

        double[] wugen1 = {88, 89, 91, 85, 74, 68, 78, 89, 60, 80, 90, 87, 85, 79, 63, 68, 69, 99, 96, 88, 92, 91, 65, 85, 75, 73, 74, 80, 70, 89};
        double[] wugen2 = {87, 66, 65, 84, 71, 86, 76, 83, 60, 70, 95, 67, 86, 75, 95, 65, 86, 79, 66, 78, 82, 71, 80, 85, 78, 89, 74, 77, 80, 91};
        double[] wugen3 = {82, 89, 88, 74, 85, 75, 63, 69, 80, 69, 73, 87, 85, 85, 65, 98, 89, 79, 96, 63, 92, 81, 75, 85, 76, 88, 73, 74, 71, 85};


//        for (int i = 0; i < age.length; i++) {
//            System.out.println("姓名:"+name[i]+" "+"年龄:"+age[i]);
//        }

        double houzi1;//代表每个学生的总分
        double houzi2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            houzi1 =  wugen1[i] +  wugen2[i] + wugen3[i];
//            houzi2 = (houzi1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" +houzi1);
//            System.out.println(name[i] + "的平均分为:" +  houzi2);
//        }



        double nali1 = 0,nali2 = 0;
        double[] zhizhuo = new double[30];
//        for (int i = 0; i < 30; i++) {
//            nali1 = wugen1[i] + wugen2[i] + wugen3[i];
//            nali2= (nali1 * 1.0) / 3;
//            zhizhuo[i] = nali2;
//        }
//
//        for (int i = 0; i <zhizhuo.length - 1; i++) {
//            for (int j = 0; j < zhizhuo.length - i - 1; j++) {
//                if (zhizhuo[j] < zhizhuo[j + 1]) {
//                    double tep = zhizhuo[j];
//                    zhizhuo[j] = zhizhuo[j + 1];
//                    zhizhuo[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(zhizhuo[i]);
//        }


        double daiwo1 = 0,daiwo2 = 0,daiwo3 = 0;//计算每门课的平均分
        double quzhao1 = 0,quzhao2 = 0,quzhao3 = 0;//计算每门课标准差
        double yiqie1 = 0,  yiqie2 = 0,yiqie3 = 0;//计算每门课中位数
        double sap = 0;
        for (int i = 0; i < wugen1.length; i++) {
            sap+=wugen1[i];
        }
        daiwo1 = (sap*1.0)/30;
        System.out.println("生物化学的班级平均分为:"+ daiwo1);
        double Sum = 0;
        for (int i = 0; i < wugen2.length; i++) {
            Sum+=wugen2[i];
        }
        daiwo2 = (Sum*1.0)/30;
        System.out.println("物理化学的班级平均分为:"+daiwo2);
        double sum = 0;
        for (int i = 0; i <wugen3.length; i++) {
            sum+=wugen3[i];
        }
        daiwo3 = (sum*1.0)/30;
        System.out.println("电子与电工技术的班级平均分为:"+ daiwo3);




        double c1 = 0,c2 = 0,c3 = 0;
        for (int i = 0; i < wugen1.length; i++) {
            c1+= (wugen1[i] - daiwo1)*(wugen1[i] -daiwo1);
        }
        quzhao1 = Math.sqrt(c1*1.0/30);
        System.out.println("生物化学的班级标准差为:"+ quzhao1);

        for (int i = 0; i <wugen2.length; i++) {
            c2+= (wugen2[i] - daiwo2)*(wugen2[i] -daiwo2);
        }
        quzhao2 = Math.sqrt(c2*1.0/30);
        System.out.println("物理化学的班级标准差为:"+ quzhao2);

        for (int i = 0; i <wugen3.length; i++) {
            c3+= (wugen3[i] - daiwo3)*(wugen3[i] - daiwo3);
        }
        quzhao3 = Math.sqrt(c3*1.0/30);
        System.out.println("电子与电工的班级标准差为:"+quzhao3);
//////
//////
//////
//        Arrays.sort(wugen1);
//        Arrays.sort(wugen2);
//        Arrays.sort(wugen3);
//        yiqie1 =( wugen1[14]+wugen1[15])*1.0/2;
//        yiqie2 =( wugen2[14]+wugen2[15])*1.0/2;
//        yiqie3 =( wugen3[14]+wugen3[15])*1.0/2;
//        System.out.println("生物化学的中位数为:"+  yiqie1);
//        System.out.println("物理化学的中位数为:"+  yiqie2);
//        System.out.println("电子与电工技术的中位数为:"+ yiqie3);


    }
}
